var hasClass = function(ele, cls){
    return ele.className.match(new RegExp('(\\s|^)' + cls + '(\\s|$)'));
}
var addClass = function(ele, cls){
    if (!hasClass(ele, cls)) {
        ele.className += " " + cls;
    }
}
var removeClass = function(ele, cls){
    if (hasClass(ele, cls)) {
        var reg = new RegExp('(\\s|^)' + cls + '(\\s|$)');
        ele.className = ele.className.replace(reg, ' ');
    }
}
var replaceClass = function(ele, oldClass, newClass){
    if (hasClass(ele, oldClass)) {
        removeClass(ele, oldClass);
        addClass(ele, newClass);
    }
    return;
}
var reset = function(){
    var backs = document.querySelectorAll(".backCalendar"), i = 0, len = backs.length;
    for (; i < len; i++) {
        removeClass(backs[i], "show");
    }
}
var currMon = document.querySelector(".calFootDateCntCurrent");
var headMon = document.querySelector(".calFootDateCntPreview");
var prev = document.querySelector("span.calFootDateArrowLeft");
var next = document.querySelector("span.calFootDateArrowRight");
var sd = new Slider(currMon, headMon, {
    previous: prev,
    next: next
});
document.querySelector(".calendarBtn").onclick = function(){
    addClass(document.querySelector(".center"), "flip");
    addClass(document.getElementById("backcalendar"), "show");
};
document.querySelector(".back").onclick = function(){
    reset();
    removeClass(document.querySelector(".center"), "flip");
};
document.querySelector(".calendarFootToday").onclick = function(){
    addClass(document.getElementById("aboutCalendar"), "show");
    addClass(document.querySelector(".center"), "flip");
};
document.querySelector(".calendarFootAdd").onclick = function(){
    addClass(document.getElementById("contactme"), "show");
    addClass(document.querySelector(".center"), "flip");
};
document.querySelector(".calendarModeList").onclick = function(){
    addClass(document.getElementById("todo"), "show");
    addClass(document.querySelector(".center"), "flip");
};
